#!/bin/sh

INSTALL_DIR="<%= install_dir %>"
PATH="$INSTALL_DIR/embedded/bin:$PATH"
export PATH

unset GEM_HOME
unset GEM_PATH
unset GEM_ROOT
unset RUBY_ENGINE
unset RUBY_ROOT

if [ -e /etc/os-release -a $(id -u) -eq 0 ]; then
  if grep -q kali /etc/os-release; then
    echo "Metasploit running on Kali Linux as root, using system database"
    if [ ! -e /usr/share/metasploit-framework/config ]; then
      mkdir -p /usr/share/metasploit-framework/config
    fi
    exec $INSTALL_DIR/embedded/framework/msfdb-kali "$@"
  fi
fi

(cd $INSTALL_DIR/embedded/framework && ruby msfdb "$@")
